package game.com.game;

/**
 * Created by maizhipeng on 2017/4/20.
 */

public class Commpany implements World.IWorldListener {
    private ICommpanyListener mICommpanyListener;
    private long mStartTime, mEndTime;
    private Persion mAbstractPersion;
    private int x = 200, y = 200;

    public Commpany() {
        World.getInstance().addIWorldListener(this);

    }


    public void startEarnMoney(Persion persion, ICommpanyListener iCommpanyListener) {
        mICommpanyListener = iCommpanyListener;
        mAbstractPersion = persion;
        mStartTime = World.getInstance().getTime();

    }



    private long moneyProdue(long startTime, long endTime) {
        long money = (endTime - startTime) / 1000 / 60 / 60;
        return money;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    @Override
    public void onTime(long time) {
        if (time - mStartTime > 8 * 3600 * 1000) {
            long mearnMoney = moneyProdue(mStartTime, time);
            if (mICommpanyListener != null) mICommpanyListener.onWorkFinish(mearnMoney);
        }

    }
}
